package com.fawkes.smartworking.helper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.fawkes.core.base.api.ApiResponseBody;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * @param <B>
 * @param <A>
 * @param <D>
 * @param <U>
 * @param <G>
 * @param <Q>
 * @param <V>
 * @param <M>
 * @param <T>
 * @param <H>
 * @author xuetieqi
 * @date 2023/4/23 11:59 AM
 */
public class BaseController<
        B extends BaseServiceImpl<M, H, A, D, U, G, Q, V, T>,
        M extends BaseMapper<T>,
        H extends BaseHelper<A, D, U, V, T>,
        A, D, U, G, Q, V, T
        > {

    @Autowired
    B baseServiceImpl;

    ApiResponseBody add(A add) {
        baseServiceImpl.insert(add);
        return ApiResponseBody.defaultSuccess();
    }


    ApiResponseBody delete(D delete) {
        baseServiceImpl.delete(delete);
        return ApiResponseBody.defaultSuccess();
    }


    ApiResponseBody update(U update) {
        baseServiceImpl.update(update);
        return ApiResponseBody.defaultSuccess();
    }


    ApiResponseBody<V> get(G get) {
        return ApiResponseBody.defaultSuccess(baseServiceImpl.get(get));
    }


    ApiResponseBody<IPage<V>> list(Q query) {
        return ApiResponseBody.defaultSuccess(baseServiceImpl.page(query));
    }


}
